home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1138 / source.zip / FRMEXTED.FRM < prev    next >
Text File  |  1995-03-07  |  8KB  |  254 lines

  1. VERSION 2.00
  2. Begin Form frmexted 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00C0C0C0&
  5.    BorderStyle     =   3  'Fixed Double
  6.    Caption         =   "External Editor"
  7.    ClientHeight    =   2208
  8.    ClientLeft      =   1308
  9.    ClientTop       =   2268
  10.    ClientWidth     =   3924
  11.    ClipControls    =   0   'False
  12.    Height          =   2628
  13.    Left            =   1260
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   2208
  18.    ScaleWidth      =   3924
  19.    Top             =   1896
  20.    Width           =   4020
  21.    Begin CommandButton cmdabort 
  22.       Cancel          =   -1  'True
  23.       Caption         =   "&Abort"
  24.       Default         =   -1  'True
  25.       Height          =   372
  26.       Left            =   2160
  27.       TabIndex        =   1
  28.       Top             =   1560
  29.       Width           =   972
  30.    End
  31.    Begin CommandButton cmdsend 
  32.       Caption         =   "&Send"
  33.       Enabled         =   0   'False
  34.       Height          =   372
  35.       Left            =   600
  36.       TabIndex        =   0
  37.       Top             =   1560
  38.       Width           =   972
  39.    End
  40.    Begin Label Label1 
  41.       Alignment       =   2  'Center
  42.       BackColor       =   &H00C0C0C0&
  43.       Height          =   852
  44.       Left            =   720
  45.       TabIndex        =   2
  46.       Top             =   240
  47.       Width           =   2292
  48.       WordWrap        =   -1  'True
  49.    End
  50. End
  51. Option Explicit
  52. Dim fname As String
  53. Dim linecount As Integer
  54. Dim flen As Long
  55.  
  56. Sub cmdabort_Click ()
  57. Dim result As Integer
  58.     
  59.     result = MsgBox("You will lose any text you entered." + Chr(10) + "Are you sure?", MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2, "Abort message " + fname + "?")
  60.     If result = IDYES Then
  61.         Kill fname
  62.         Unload frmexted
  63.     End If
  64. End Sub
  65.  
  66. Sub cmdsend_Click ()
  67. Dim result As Integer
  68. Dim foldername As String
  69. Dim newfname As String
  70.  
  71.     If FileLen(fname) = flen Then
  72.         result = MsgBox("Are you sure you saved the file?", MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2, "File size unchanged")
  73.         If result = IDNO Then Exit Sub
  74.     End If
  75.  
  76.     ' Copy message to posted folder
  77.     foldername = GetINI("Folders", "CreatedTo", "Sent Messages")
  78.     Call CreateFolder(foldername)
  79.     SaveFiletoFolder fname, foldername
  80.     
  81.     ' Change from .TMP to .MSG and Post it as SOUP replies packet
  82.     newfname = Mid$(fname$, 1, Len(fname$) - 3) + "MSG"
  83.     Name fname As newfname
  84.     result = Post(newfname, replytype) 'post mail or news
  85.  
  86.     Unload frmexted
  87. End Sub
  88.  
  89. Function CreateMessage () As Integer
  90. Dim uniq As Integer, result As Integer
  91. Dim fout As Integer
  92. Dim sigout As Integer
  93. Dim sigline As String
  94. Dim sigfname As String
  95. Dim ptr, column As Integer
  96. Dim replyto, organization As String
  97. Dim refer As String
  98.  
  99.     ' Do headers
  100.     refer = ""
  101.     If mailsendto = "" Then mailsendto = InputBox$("Who is this message to?", "New Message", "")
  102.     If mailsendto = "" Then
  103.         CreateMessage = 1
  104.         Exit Function
  105.     End If
  106.     If mailsubject = "" Then mailsubject = InputBox$("What is this message's Subject?", "New Message", "")
  107.     If mailsubject = "" Then
  108.         CreateMessage = 1
  109.         Exit Function
  110.     End If
  111.     
  112.     ChDrive App.Path
  113.     ChDir App.Path
  114.  
  115.     ' Get a unique filename (PBR00N.MSG)
  116.     uniq = Val(GetINI("Message", "LastMessage", "1"))
  117.     uniq = uniq + 1
  118.     SetINI "Message", "LastMessage", Format$(uniq)
  119.     If replytype = 1 Then
  120.         fname = App.Path + "\PBM" + Format$(uniq, "000") + ".TMP"
  121.     Else
  122.         fname = App.Path + "\PBN" + Format$(uniq, "000") + ".TMP"
  123.     End If
  124.     
  125.     fout = FreeFile
  126.     Open fname For Output As fout
  127.     linecount = 0
  128.  
  129.     If replytype = 1 Then
  130.         Print #fout, "To: " + mailsendto
  131.         linecount = linecount + 1
  132.         If mailreferences <> "" Then
  133.             Print #fout, "References: " + mailreferences
  134.             linecount = linecount + 1
  135.             refer = "In article " + fixstr(GetHeader("Message-ID")) + ", you wrote:"
  136.         End If
  137.     Else
  138.         Print #fout, "Newsgroups: " + mailsendto
  139.         linecount = linecount + 1
  140.         If mailreferences <> "" Then
  141.             Print #fout, "References: " + mailreferences
  142.             linecount = linecount + 1
  143.             refer = "In article " + fixstr(GetHeader("Message-ID")) + ", " + fixstr(GetHeader("From")) + " wrote:"
  144.         End If
  145.     End If
  146.     Print #fout, "Subject: " + mailsubject
  147.     linecount = linecount + 1
  148.     If UCase$(GetINI("Message", "PostDate", "N")) = "Y" Then
  149.         Print #fout, "Date: " + fixstr(GetGMTime())
  150.         linecount = linecount + 1
  151.     End If
  152.     
  153. ' Optional Reply-To
  154.     replyto = GetINI("Message", "Reply-To", "")
  155.     If Len(replyto) > 2 Then
  156.         Print #fout, "Reply-To: " + replyto
  157.         linecount = linecount + 1
  158.     End If
  159.     
  160. ' Optional Organization
  161.     organization = GetINI("Message", "Organization", "")
  162.     If Len(organization) > 2 Then
  163.         Print #fout, "Organization: " + organization
  164.         linecount = linecount + 1
  165.     End If
  166.  
  167.     Print #fout,  ' Blank line seperates headers from message
  168.     linecount = linecount + 1
  169.     
  170.     If mailreferences <> "" Then
  171.     ' It's a reply, quote previous message
  172.         Print #fout, refer
  173.         linecount = linecount + 1
  174.         For ptr = endofheaders() To GetNumLines()
  175.             Print #fout, ">"; fixstr(GetLine(ptr))
  176.             linecount = linecount + 1
  177.             If linecount > Val(GetINI("Editor", "MaxLinesQuote", "100")) Then
  178.                 Print #fout, "> ... (Message Truncated)"
  179.                 MsgBox "Too many lines to quote (" + Format$(linecount) + ")", MB_ICONEXCLAMATION, "Truncated"
  180.                 Exit For
  181.             End If
  182.         Next ptr
  183.         Print #fout, 'Blank line after quote
  184.         linecount = linecount + 1
  185.     End If
  186.     
  187.     Print #fout,
  188.  
  189.     ' Do signature
  190.     sigfname = GetINI("Message", "Signature-File", App.Path + "\SIG.TXT")
  191.     If FileExists(sigfname) Then
  192.         sigout = FreeFile
  193.         Open sigfname For Input As sigout
  194.         Print #fout, "-- "  ' Begin signature signature
  195.         While Not EOF(sigout)
  196.             Line Input #sigout, sigline
  197.             Print #fout, sigline
  198.         Wend
  199.         Close sigout
  200.         Else
  201.             ' Default signature ?
  202.     End If
  203.     Close fout
  204.     CreateMessage = 0
  205. End Function
  206.  
  207. Sub Form_Activate ()
  208. Dim x As Integer
  209. Dim z As Integer
  210. Dim editor As String
  211. Dim result As Integer
  212.  
  213.     result = CreateMessage()
  214.     If result = 1 Then
  215.         Unload frmexted
  216.         Exit Sub
  217.     End If
  218.  
  219.     flen = FileLen(fname)
  220.     
  221.     Label1.Caption = "Please edit and save the file " + fname
  222.     editor = GetINI("Editor", "ExternalEditor", "notepad.exe")
  223.     editor = editor + " " + fname
  224.  
  225.     x = Shell(editor, 3)
  226.     ' Skip down to right before the signatures
  227.     For z = 1 To linecount
  228.         SendKeys "{DOWN}"
  229.     Next z
  230.  
  231.     'While FileLen(fname) = flen
  232.     '    z = DoEvents()
  233.     'Wend
  234.     'While GetModuleUsage(x) > 0
  235.     '    z = DoEvents()
  236.     'Wend
  237.     cmdsend.Enabled = True
  238.     cmdsend.Default = True
  239.     cmdabort.Default = False
  240.     'Label1.Caption = "Send message " + fname + "?"
  241.  
  242. End Sub
  243.  
  244. Sub Form_Load ()
  245. Dim x As Integer
  246. Dim z As Integer
  247. Dim editor As String
  248.  
  249.     frmexted.Left = (screen.Width - frmexted.Width) / 2
  250.     frmexted.Top = (screen.Height - frmexted.Height) / 2
  251.     cmdsend.Enabled = False
  252. End Sub
  253.  
  254.